package com.ruoyi.project.jiaqin.supplyclasskey.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.project.jiaqin.supplyclassval.mapper.SupplyClassAttrValMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.jiaqin.supplyclasskey.mapper.SupplyClassAttrKeyMapper;
import com.ruoyi.project.jiaqin.supplyclasskey.domain.SupplyClassAttrKey;
import com.ruoyi.project.jiaqin.supplyclasskey.service.ISupplyClassAttrKeyService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 分类属性名Service业务层处理
 *
 * @author admin
 * @date 2021-01-28
 */
@Service
public class SupplyClassAttrKeyServiceImpl implements ISupplyClassAttrKeyService
{
    @Autowired
    private SupplyClassAttrKeyMapper supplyClassAttrKeyMapper;
    @Autowired
    private SupplyClassAttrValMapper supplyClassAttrValMapper;

    /**
     * 查询分类属性名
     *
     * @param id 分类属性名ID
     * @return 分类属性名
     */
    @Override
    public SupplyClassAttrKey selectSupplyClassAttrKeyById(String id)
    {
        return supplyClassAttrKeyMapper.selectSupplyClassAttrKeyById(id);
    }

    /**
     * 查询分类属性名列表
     *
     * @param supplyClassAttrKey 分类属性名
     * @return 分类属性名
     */
    @Override
    public List<SupplyClassAttrKey> selectSupplyClassAttrKeyList(SupplyClassAttrKey supplyClassAttrKey)
    {
        List<SupplyClassAttrKey> list = supplyClassAttrKeyMapper.selectSupplyClassAttrKeyList(supplyClassAttrKey);
        if(list != null && list.size() != 0){
            for (SupplyClassAttrKey c:list) {
                //查询属性值
                c.setVals(supplyClassAttrValMapper.selectSupplyClassAttrValListByAttrKeyId(c.getId()));
            }
        }
        return list;
    }

    /**
     * 新增分类属性名
     *
     * @param supplyClassAttrKey 分类属性名
     * @return 结果
     */
    @Override
    public int insertSupplyClassAttrKey(SupplyClassAttrKey supplyClassAttrKey)
    {
        supplyClassAttrKey.setId(UUID.randomUUID().toString().replace("-",""));
        return supplyClassAttrKeyMapper.insertSupplyClassAttrKey(supplyClassAttrKey);
    }

    /**
     * 修改分类属性名
     *
     * @param supplyClassAttrKey 分类属性名
     * @return 结果
     */
    @Override
    public int updateSupplyClassAttrKey(SupplyClassAttrKey supplyClassAttrKey)
    {
        return supplyClassAttrKeyMapper.updateSupplyClassAttrKey(supplyClassAttrKey);
    }

    /**
     * 删除分类属性名对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSupplyClassAttrKeyByIds(String ids)
    {
        return supplyClassAttrKeyMapper.deleteSupplyClassAttrKeyByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除分类属性名信息
     *
     * @param id 分类属性名ID
     * @return 结果
     */
    @Override
    public int deleteSupplyClassAttrKeyById(String id)
    {
        return supplyClassAttrKeyMapper.deleteSupplyClassAttrKeyById(id);
    }
}
